<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script type="text/javascript"
	src="<%=basePath%>demo/js/jquery-1.9.1.min.js"">
	
</script>


<c:if test="${  empty sessionScope.user}">
<script type="text/javascript">
function check(form)

{
	form.target="_top";
return true;
	}
</script>
</c:if>

<c:if test="${  !empty sessionScope.user}">
<script type="text/javascript">
function check(form)

{

	return true;
	}
</script>
</c:if>


<head>
<base href="<%=basePath%>">

<title>allBooks.jsp</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<style type="text/css">


td {
	
	text-align: center;
}

</style>
</head>


<script type="text/javascript">
	<c:if test="${requestScope.log==1 }">

	alert("已经是最后一页");

	</c:if>
	<c:if test="${requestScope.log==2 }">

	alert("已经是第一页");

	</c:if>
	<c:if test="${requestScope.log==3 }">

	alert("对不起没有符合您查询的图书");
	window.location.href="book/bookAction_findBooktype";

	</c:if>
</script>
<body>
	<!-- 此处的hidden域是为了 查询分页，要求下一页依旧能获取到book参数-->
	<form action="book/bookAction_findBooks" id="page" method="post">
		<input type="hidden" name="pageNum" id="pageNum"> <input
			type="hidden" name="book.bookauthor"
			value="${requestScope.book.bookauthor }">
			
			<input
			type="hidden" name="book.booktype.idBooktype "
			value="${requestScope.book.booktype.idBooktype }"> 
			 <input
			type="hidden" name="book.bookname"
			value="${requestScope.book.bookname }"> <input type="hidden"
			name="book.publish" value="${requestScope.book.publish }">
	</form>

<input type="hidden" id=now value=${requestScope.pageNum }>
	<div>
		<c:forEach items="${requestScope.books}" var="bk">

			<span style="width: 220">
				<table style="border-width: 3;border-color: black;border-style: solid;height: 270">
					

					<tr>
						<td colspan="2" >
							<img src="${bk.bookimage}"  style="height: 150">
						</td>
						
					</tr>
					
						<tr><td colspan="2">名称：${bk.bookname }</td></tr>
					<tr>
						<td colspan="2">作者：${bk.bookauthor }</td></tr>
						
						
							

					<tr>
						
						
							<td style="width: 120">原价：<a style="text-decoration: line-through;color: gray;" >
							<c:forEach items="${bk.prices }" var="price">
							<c:if test="${price.utype.idUtype=='uuid_0'  }">
							
							
							${price.realprice }
							
							</c:if>
							
							
							
							
							
							</c:forEach>
							&nbsp;
							
							</a>
							</td>
							
							
							<td style="width:120;height: 50">现价：<a style="font-size: 25;font: bolder;color: red" >
						<c:if test="${ empty sessionScope.user}">
					
							
							<c:forEach items="${bk.prices }" var="price">
							<c:if test="${price.utype.idUtype=='uuid_0'  }">
							
							
							${price.realprice }
							
							</c:if>
							
							
							
							
							
							</c:forEach>
							
							</a>
					</c:if>
							<c:if test="${ !empty sessionScope.user}">
					
							
							<c:forEach items="${bk.prices }" var="price">
							<c:if test="${price.utype.idUtype==sessionScope.user.utype.idUtype  }">
							${price.realprice }
							
							
							</c:if></c:forEach>
							
							
					</c:if>	
							</td>
					</tr>
					
					
					<tr><td colspan="2">
									 <!--点击购买按钮提交form表单，为了点击购买后依旧保持查询条件   -->
							<form action="book/bookAction_buy " method="post" onsubmit="check(this)">
								<input type="hidden" name="book.bookauthor"
									value="${requestScope.book.bookauthor}" /> <input type="hidden"
									name="book.publish" value="${requestScope.book.publish}" /> <input
									type="hidden" name="book.bookname"
									value="${requestScope.book.bookname}" /> 
									<input type="hidden"
									name="idBook" value="${bk.idBook}" />
									
									
									<input
			type="hidden" name="book.booktype.idBooktype "
			value="${requestScope.book.booktype.idBooktype }"> <input type="submit"
									style=" margin-top:10;float:right;background-color:orange;
								padding-top:3;border-style: none;background-image: url('img/goumai.gif');width: 72"
									value="">
									
									
									 <input	type="hidden" name="pageNum"/> 
									
									
							</form>
							</td></tr>
				</table>

			</span>


		</c:forEach>
	</div>
	<!-- 
<a href="book/bookAction_findBooks?pageNum=1"> 首页   </a>
  <a href="book/bookAction_findBooks?pageNum=${requestScope.pageNum-1 }">上一页   </a>
<c:forEach begin="1" end="${requestScope.pageCount }" varStatus="ss" >
 <a href="book/bookAction_findBooks?pageNum=${ss.index }">   ${ss.index }    </a>
 &nbsp;
</c:forEach>
<a href="book/bookAction_findBooks?pageNum=${requestScope.pageNum+1 }"> 下一页   </a>
  <a href="book/bookAction_findBooks?pageNum=${requestScope.pageCount}">尾页  </a>
     -->
<div style="text-align: center;">
	<a pageNum="1" href="javascript: void(0)">首页</a>
	<a pageNum="${requestScope.pageNum-1 }" href="javascript: void(0)">上一页</a>
	&nbsp;&nbsp;
	<c:forEach begin="1" end="${requestScope.pageCount }" varStatus="ss">
		<a pageNum="${ss.index }" href="javascript: void(0)"> ${ss.index }
		</a>
 &nbsp;
</c:forEach>
	&nbsp;&nbsp;

	<a pageNum="${requestScope.pageNum+1 }" href="javascript: void(0)">下一页</a>
	<a pageNum="${requestScope.pageCount}" href="javascript: void(0)">尾页</a>
	<script type="text/javascript">
		$(function() {
			
			$("form").submit( function () {$("input[name='pageNum']").val($("#now").val());
				 return true;
				} );
		
			$("a[pageNum]").click(function() {
				$("#pageNum").val($(this).attr("pageNum"));
				document.getElementById("page").submit();
			});
		})
	</script>

</div>


</body>
</html>
